//
//  MTabViewController.swift
//  CHT
//
//  Created by aiquantong on 2019/2/20.
//  Copyright © 2019 difan. All rights reserved.
//

import UIKit

class MTabViewController: UITabBarController, UITabBarControllerDelegate {
    
    var homeViewController:HomeViewController!
    var chatHomeViewController:ChatHomeViewController!
    var matchHomeViewController:MatchHomeViewController!
    var meHomeViewController:MeHomeViewController!
    var webViewController:WebViewController!
    var centerButton:UIButton!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "首页"
        self.initTabBarController();
        // Do any additional setup after loading the view.
    }
    
    func initTabBarController()  {
        homeViewController = HomeViewController.init(nibName: "HomeViewController", bundle: nil);
        homeViewController.tabBarItem = UITabBarItem.init();
        homeViewController.tabBarItem.title = "首页";
        homeViewController.tabBarItem.image = UIImage(named: "new_tab_home");
        homeViewController.tabBarItem.selectedImage = UIImage(named: "new_tab_home");
        
        chatHomeViewController = ChatHomeViewController.init(nibName: "ChatHomeViewController", bundle: nil);
        chatHomeViewController.tabBarItem = UITabBarItem.init();
        chatHomeViewController.tabBarItem.title = "朋友";
        chatHomeViewController.tabBarItem.image = UIImage(named: "new_tab_chat");
        chatHomeViewController.tabBarItem.selectedImage = UIImage(named: "new_tab_chat");
        
        matchHomeViewController = MatchHomeViewController.init(nibName: "MatchHomeViewController", bundle: nil);
        matchHomeViewController.tabBarItem = UITabBarItem.init();
        matchHomeViewController.tabBarItem.title = "";
        matchHomeViewController.tabBarItem.image = UIImage(named: "new_tab_match");
        matchHomeViewController.tabBarItem.selectedImage = UIImage(named: "new_tab_match");
        
        meHomeViewController = MeHomeViewController.init(nibName: "MeHomeViewController", bundle: nil);
        meHomeViewController.tabBarItem = UITabBarItem.init();
        meHomeViewController.tabBarItem.title = "会员中心";
        meHomeViewController.tabBarItem.image = UIImage(named: "new_tab_me");
        meHomeViewController.tabBarItem.selectedImage = UIImage(named: "new_tab_me");
        
        webViewController = WebViewController.init(nibName: "WebViewController", bundle: nil);
        webViewController.tabBarItem = UITabBarItem.init();
        webViewController.tabBarItem.title = "帮助";
        webViewController.tabBarItem.image = UIImage(named: "new_tab_help");
        webViewController.tabBarItem.selectedImage = UIImage(named: "new_tab_help");
        
        let vcArr : NSArray = [homeViewController,chatHomeViewController,matchHomeViewController,meHomeViewController,webViewController];
        self.viewControllers = vcArr as? [UIViewController];
        self.delegate = self;
        self.title = "首页";
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated);
        self.navigationController?.setNavigationBarHidden(false, animated: animated);
    }

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
